#pragma once

#include <iostream>


#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)

#define CONV(v) (struct sockaddr *)(v)

enum 
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    LISTEN_ERR,
    ARGC_ERR
};
#define backlog 8 
const int gsockfd = -1;
//GET / HTTP/1.1 \r\n
bool ParseOneLine(std::string & req_str,std::string * out_string,const std::string  Sep)
{   
    auto pos = req_str.find(Sep);
    if(pos==std::string::npos) return false;
    *out_string = req_str.substr(0,pos);
    req_str.erase(0,pos+Sep.size());
    return true;
}
bool SplitHeadKv(std::string & one_head,const std::string HeadLineSep,std::string *  key,std::string *value)
{
    auto pos = one_head.find(HeadLineSep);
    if(pos==std::string::npos) return false;
    *key=one_head.substr(0,pos);
    *value = one_head.substr(pos+HeadLineSep.size());
    return true;
}


